import { reactive } from "vue";
import { getById } from "@/api/health";

const uploadServerUrl = `${import.meta.env.VITE_API_SERVER}`;

export const _$ = reactive({
  requestParam: {
    id: null,
  },
  responseParam: {},
});

export const $ = {
  loadDetail() {
    getById(_$.requestParam.id).then((data) => {
      _$.responseParam = data;
    });
  },

  onDownload(fileUrl) {
    fetch(fileUrl).then((res) =>
      res.blob().then((blob) => {
        let a = document.createElement("a");
        let url = window.URL.createObjectURL(blob);
        a.href = url;
        a.download = "体检文件";
        a.click();
        window.URL.revokeObjectURL(url);
      })
    );
  },

  clean() {
    _$.responseParam = {};
  },
};

export const to = {};
